package edu.java.water.mapper;

import edu.java.water.entity.UserEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserMapper {
    @Select("select * from user left join building on user.buildingId=building.id where openId=#{openId}")
    UserEntity selectUserOpenId(@Param("openId") String openId);

    @Select("select * from user where openId=#{openId} and state=#{state}")
    UserEntity selectUserState(@Param("openId") String openId,@Param("state") String state);

    @Insert("insert into user(openId,username) values(#{openId},#{username})")
    int InsertUser(@Param("openId")String openId,@Param("username")String username);

    @Update("update user set username=#{username},buildingId=#{buildingId},address=#{address},phone=#{phone},name=#{name} where openId=#{openId}")
    int setUserData(UserEntity userEntity);
}
